package com.cnap.model.schedule.engine;

/**
 * 策略参数枚举
 *
 * @author xc
 **/
public enum PolicyParamEnum {
    // 负载
    LOAD_POLICY("load", "loadFactor"),
    // 成本
    PRICE_POLICY("price", "priceConfig"),
    // sla
    SLA_POLICY("sla", "slaConfig"),
    // 能源
    ENERGY_POLICY("energy", "energyConfig"),
    // 非法
    INVALID("invalid", "invalidConfig"),
    ;
    // 策略名称
    private final String name;
    // 参数名称
    private final String paramName;

    PolicyParamEnum(String name, String paramName) {
        this.name = name;
        this.paramName = paramName;
    }

    /**
     * get
     *
     * @return Name
     */
    public String getName() {
        return name;
    }

    /**
     * get
     *
     * @return ParamName
     */
    public String getParamName() {
        return paramName;
    }

    /**
     * 根据策略名称获取枚举
     *
     * @param policyName 策略名称
     * @return 结果
     */
    public static PolicyParamEnum getPolicyParamEnumByPolicyName(String policyName) {
        PolicyParamEnum[] policyParamEnums = PolicyParamEnum.values();
        for (PolicyParamEnum policyParamEnum : policyParamEnums) {
            if (policyParamEnum.getName().equals(policyName)) {
                return policyParamEnum;
            }
        }
        return INVALID;
    }
}
